package com.lkj.service.impl;

import com.lkj.entity.SysUserPost;
import com.lkj.dao.SysUserPostDao;
import com.lkj.service.SysUserPostService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户与岗位关联表(SysUserPost)表服务实现类
 *
 * @author makejava
 * @since 2020-09-13 10:39:03
 */
@Service("sysUserPostService")
public class SysUserPostServiceImpl implements SysUserPostService {
    @Resource
    private SysUserPostDao sysUserPostDao;

    /**
     * 通过ID查询单条数据
     *
     * @param userId 主键
     * @return 实例对象
     */
    @Override
    public SysUserPost queryById(Long userId) {
        return this.sysUserPostDao.queryById(userId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<SysUserPost> queryAllByLimit(int offset, int limit) {
        return this.sysUserPostDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param sysUserPost 实例对象
     * @return 实例对象
     */
    @Override
    public SysUserPost insert(SysUserPost sysUserPost) {
        this.sysUserPostDao.insert(sysUserPost);
        return sysUserPost;
    }

    /**
     * 修改数据
     *
     * @param sysUserPost 实例对象
     * @return 实例对象
     */
    @Override
    public SysUserPost update(SysUserPost sysUserPost) {
        this.sysUserPostDao.update(sysUserPost);
        return this.queryById(sysUserPost.getUserId());
    }

    /**
     * 通过主键删除数据
     *
     * @param userId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long userId) {
        return this.sysUserPostDao.deleteById(userId) > 0;
    }
}